Page({
    data: {
        type: '', // 0售后规定 2交易规则 3运输说明 4等级标准 5关于我们 6推广说明 8用户服务协议
        article_content: ''
    },
    onLoad: function(options) {
        const type = Number(options.type)
        const article_id = options.article_id
        this.setData({ type })
        let url = `/api/article/detail?article_id=${article_id ? article_id : ['10', '', '6', '7', '8', '9', '12','','21'][type]}`
        this.request({
            url,
            loadingTip: '加载中',
            login: false
        }, res => {
            // let article_content = res.data.article_content.content.replaceAll('color="', 'style="color:').replaceAll('" style="', '')
            let article_content = res.data.article_content.content.replaceAll('<table>', '<table border="1px solid #000" cellspacing="0" cellpadding="6">')
            wx.setNavigationBarTitle({
                title: res.data.title,
            })
            this.setData({ article_content })
        })
        if (options.uid) { //页面分享携带uid绑定关系
            this.redirect_login(options.uid)
        }
    },
    //点击分享
    onShareAppMessage() {
        //获取当前页面的参数
        const pages = getCurrentPages()
        const currentPage = pages[pages.length - 1]
        let params = currentPage.options
        let key = Object.keys(params)[0]
        let options = '/pages/article/index?' + key + '=' + params[key]
        if (this.data.userInfo) options += `&uid=${this.data.userInfo.uid}`
        return {
            path: options
        }
    },
})